package com.zhuojy.equity.mall.admin.web.controller;

import com.zhuojy.equity.mall.admin.common.entity.TMoney;
import com.zhuojy.equity.mall.admin.common.entity.vo.TMoneyVO;
import com.zhuojy.equity.mall.admin.common.pojo.JsonResult;
import com.zhuojy.equity.mall.admin.service.TMoneyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "往来收款管理")
@RestController
@RequiredArgsConstructor
@RequestMapping("TMoney")
@CrossOrigin
public class TMoneyController {
    @Autowired
    private TMoneyService tMoneyService;
    /**
     * 应收款条查分页
     */
    @ApiOperation(value = "应收款条查分页", httpMethod = "POST", notes = "应收款条查分页")
    @RequestMapping("findTMoneyPagination")
    public JsonResult findTMoneyPagination(@RequestBody TMoney tMoney, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize){
        return tMoneyService.findTMoneyPagination(tMoney,pageNum,pageSize);
    }
    /**
     * 应收款回显
     */
    @ApiOperation(value = "应收款回显", httpMethod = "POST", notes = "应收款回显")
    @RequestMapping("findTMoneyById")
    public TMoneyVO findTMoneyById(Long id){
        return tMoneyService.findTMoneyById(id);
    }
    /**
     * 应收款删除
     */
    @ApiOperation(value = "应收款删除", httpMethod = "POST", notes = "应收款删除")
    @RequestMapping("deleteTMonyById")
    public JsonResult deleteTMonyById(Long id){
        try {
            tMoneyService.deleteTMonyById(id);
            return JsonResult.success(200,"删除成功");
        } catch (Exception e) {
            e.printStackTrace();
            return JsonResult.success(444,"删除失败");
        }
    }
    /**
     * 收款明细-类型条查-动态下拉
     */
    @ApiOperation(value = "收款明细-类型条查-动态下拉", httpMethod = "POST", notes = "收款明细-类型条查-动态下拉")
    @RequestMapping("findOptions")
    public List<TMoney> findOptions(){
        return tMoneyService.findOptions();
    }
}
